package com.tanhua.server.controller;

import com.tanhua.model.vo.QuestionnaireVo;
import com.tanhua.model.vo.ViewreportVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description: 测试灵魂
 * @author: zhangzheng
 * @date: 2021/12/25 16:55
 */
@RestController
@RequestMapping("/testSoul")
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    /**
     *  提交问卷 zhengzheng、liuhaijie、zhangfude
     * @param param answers
     * @return 报告Id
     */
    @PostMapping
    public ResponseEntity<String> submitQuestionnaire(@RequestBody Map<String,List<Map<String,String>>> param){
        String reportId = testSoulService.submitQuestionnaire(param);
        return ResponseEntity.ok(reportId);
    }


    /**
     * 查看结果
     * @param id
     * @return
     */
    @GetMapping("/report/{id}")
    public ResponseEntity viewResults(@PathVariable("id") String id) {
        ViewreportVo viewreportVo = testSoulService.viewResults(id);
        return ResponseEntity.ok(viewreportVo);
    }

    /**
     * 问卷列表
     * @return
     */
    @GetMapping
    public ResponseEntity questionnaireList(){
        List<QuestionnaireVo> listVo = testSoulService.questionnaireList();
        return ResponseEntity.ok(listVo);
    }
}
